<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?=$form->getTitle()?></title>
    <script type="text/javascript" src="__ADMIN_PATH__js/formbuilder/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN_PATH__js/formbuilder/vue.min.js"></script>
    <link href="__ADMIN_PATH__js/formbuilder/iview.css" rel="stylesheet">
    <script type="text/javascript" src="__ADMIN_PATH__js/formbuilder/iview.min.js"></script>
    <script type="text/javascript" src="__ADMIN_PATH__js/formbuilder/form-create.min.js"></script>
    <script type="text/javascript" src="__ADMIN_PATH__js/formbuilder/province_city.js"></script>
    <script type="text/javascript" src="__ADMIN_PATH__js/formbuilder/province_city_area.js"></script>
    <style>
        .ivu-modal-footer{
            display: none;
        }
    </style>
</head>
<body>
<script>
    window.$f = null;
    // 回调
    formCreate.formSuccess = function(res){
        setTimeout(function (){
            parent.location.reload();
        }, 2000);
    };

    // 构建表单
    (function () {
        var create = (function() {
                var e = function(l, k) {
                    return Object.prototype.toString.call(l) === ("[object " + k + "]")
                };
                var g = function(k) {
                    k.forEach(function(n) {
                        var m = n.type ? ("" + n.type).toLocaleLowerCase() : ""
                            , l = e(k.children, "Array") ? k.children : [];
                        if ((m === "cascader" || m === "tree") && n.props) {
                            if (n.props.data && e(n.props.data, "String") && n.props.data.indexOf("js.") === 0) {
                                n.props.data = window[n.props.data.substr(3)]
                            } else {
                                if (n.props.options && e(n.props.options, "String") && n.props.options.indexOf("js.") === 0) {
                                    n.props.options = window[n.props.options.substr(3)]
                                }
                            }
                        }
                        if (l.length) {
                            g(l)
                        }
                    });
                    return k
                };
                var i = function(k, l, m, n) {
                    $.ajax({
                        url: k,
                        type: ("" + l).toLocaleUpperCase(),
                        dataType: "json",
                        headers: c,
                        contentType: j,
                        data: m,
                        success: function(o) {
                            n(1, o)
                        },
                        error: function() {
                            n(0, {})
                        }
                    })
                };
                var h = g(<?=$form->parseFormRule()?>)
                    , c = {}
                    , d = {}
                    , j = "<?=$form->getFormContentType()?>"
                    , f = "<?=$form->getAction()?>"
                    , a = "<?=$form->getMethod()?>"
                    , b = new Vue();
                if (!b.$Message && b.$message) {
                    Vue.prototype.$Message = b.$message
                }
                return function(l) {
                    if (!l) {
                        l = {}
                    }
                    if (l.el) {
                        d.el = l.el
                    }
                    d.onSubmit = function(m) {
                        k.submitBtnProps({
                            loading: true,
                            disabled: true
                        });
                        i(f, a, m, function(n, o) {
                            if (l.callback) {
                                return l.callback(n, o, k)
                            }
                            k.submitBtnProps({
                                loading: false,
                                disabled: false
                            });
                            if (n && o.code === 200) {
                                b.$Message.success(o.msg || "表单提交成功")
                                formCreate.formSuccess && formCreate.formSuccess(o);
                            } else {
                                b.$Message.error(o.msg || "表单提交失败")
                            }
                        })
                    }
                    ;
                    d.global = {
                        upload: {
                            props: {
                                onExceededSize: function(m) {
                                    b.$Message.error(m.name + "超出指定大小限制")
                                },
                                onFormatError: function() {
                                    b.$Message.error(file.name + "格式验证失败")
                                },
                                onError: function(m) {
                                    b.$Message.error(file.name + "上传失败,(" + m + ")")
                                },
                                onSuccess: function(n, m) {
                                    if (n.code === 200) {
                                        m.url = n.data.filePath
                                    } else {
                                        b.$Message.error(n.msg)
                                    }
                                }
                            }
                        }
                    };
                    var k = formCreate.create(h, d);
                    return k
                }
            }
        )();
        window.$f = create();
    })()

</script>
</body>
</html>